.class public Lcom/adview/adapters/GreystripeAdapter;
.super Lcom/adview/adapters/AdViewAdapter;
.source "GreystripeAdapter.java"

# interfaces
.implements Lcom/greystripe/android/sdk/BannerListener;


# direct methods
.method public constructor <init>(Lcom/adview/AdViewLayout;Lcom/adview/obj/Ration;)V
    .locals 0
    .parameter "adViewLayout"
    .parameter "ration"

    .prologue
    .line 21
    invoke-direct {p0, p1, p2}, Lcom/adview/adapters/AdViewAdapter;-><init>(Lcom/adview/AdViewLayout;Lcom/adview/obj/Ration;)V

    .line 23
    return-void
.end method


# virtual methods
.method public handle()V
    .locals 6

    .prologue
    .line 30
    invoke-static {}, Lcom/adview/AdViewTargeting;->getRunMode()Lcom/adview/AdViewTargeting$RunMode;

    move-result-object v4

    sget-object v5, Lcom/adview/AdViewTargeting$RunMode;->TEST:Lcom/adview/AdViewTargeting$RunMode;

    if-ne v4, v5, :cond_0

    .line 31
    const-string v4, "AdView SDK v1.7.0"

    const-string v5, "Into Greystripe"

    invoke-static {v4, v5}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 32
    :cond_0
    iget-object v4, p0, Lcom/adview/adapters/GreystripeAdapter;->adViewLayoutReference:Ljava/lang/ref/WeakReference;

    invoke-virtual {v4}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/adview/AdViewLayout;

    .line 33
    .local v1, adViewLayout:Lcom/adview/AdViewLayout;
    if-nez v1, :cond_2

    .line 54
    :cond_1
    :goto_0
    return-void

    .line 37
    :cond_2
    :try_start_0
    iget-object v4, v1, Lcom/adview/AdViewLayout;->activityReference:Ljava/lang/ref/WeakReference;

    invoke-virtual {v4}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/app/Activity;

    .line 38
    .local v0, activity:Landroid/app/Activity;
    if-eqz v0, :cond_1

    .line 41
    invoke-virtual {v0}, Landroid/app/Activity;->getApplicationContext()Landroid/content/Context;

    move-result-object v4

    iget-object v5, p0, Lcom/adview/adapters/GreystripeAdapter;->ration:Lcom/adview/obj/Ration;

    iget-object v5, v5, Lcom/adview/obj/Ration;->key:Ljava/lang/String;

    invoke-static {v4, v5}, Lcom/greystripe/android/sdk/GSSDK;->initialize(Landroid/content/Context;Ljava/lang/String;)Lcom/greystripe/android/sdk/GSSDK;

    .line 42
    new-instance v2, Lcom/greystripe/android/sdk/BannerView;

    invoke-direct {v2, v0}, Lcom/greystripe/android/sdk/BannerView;-><init>(Landroid/content/Context;)V

    .line 44
    .local v2, banner:Lcom/greystripe/android/sdk/BannerView;
    invoke-virtual {v2, p0}, Lcom/greystripe/android/sdk/BannerView;->addListener(Lcom/greystripe/android/sdk/BannerListener;)V

    .line 48
    invoke-virtual {v2}, Lcom/greystripe/android/sdk/BannerView;->refresh()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 50
    .end local v0           #activity:Landroid/app/Activity;
    .end local v2           #banner:Lcom/greystripe/android/sdk/BannerView;
    :catch_0
    move-exception v4

    move-object v3, v4

    .line 51
    .local v3, e:Ljava/lang/Exception;
    invoke-virtual {v1}, Lcom/adview/AdViewLayout;->rotatePriAd()V

    goto :goto_0
.end method

.method public onFailedToReceiveAd(Lcom/greystripe/android/sdk/BannerView;)V
    .locals 3
    .parameter "arg0"

    .prologue
    .line 59
    invoke-static {}, Lcom/adview/AdViewTargeting;->getRunMode()Lcom/adview/AdViewTargeting$RunMode;

    move-result-object v1

    sget-object v2, Lcom/adview/AdViewTargeting$RunMode;->TEST:Lcom/adview/AdViewTargeting$RunMode;

    if-ne v1, v2, :cond_0

    .line 60
    const-string v1, "AdView SDK v1.7.0"

    const-string v2, "Greystripe fail"

    invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 61
    :cond_0
    invoke-virtual {p1, p0}, Lcom/greystripe/android/sdk/BannerView;->removeListener(Lcom/greystripe/android/sdk/BannerListener;)V

    .line 62
    iget-object v1, p0, Lcom/adview/adapters/GreystripeAdapter;->adViewLayoutReference:Ljava/lang/ref/WeakReference;

    invoke-virtual {v1}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/adview/AdViewLayout;

    .line 63
    .local v0, adViewLayout:Lcom/adview/AdViewLayout;
    if-nez v0, :cond_1

    .line 69
    :goto_0
    return-void

    .line 66
    :cond_1
    iget-object v1, v0, Lcom/adview/AdViewLayout;->adViewManager:Lcom/adview/AdViewManager;

    invoke-virtual {v1}, Lcom/adview/AdViewManager;->resetRollover_pri()V

    .line 67
    invoke-virtual {v0}, Lcom/adview/AdViewLayout;->rotateThreadedPri()V

    goto :goto_0
.end method

.method public onReceivedAd(Lcom/greystripe/android/sdk/BannerView;)V
    .locals 3
    .parameter "arg0"

    .prologue
    .line 74
    invoke-static {}, Lcom/adview/AdViewTargeting;->getRunMode()Lcom/adview/AdViewTargeting$RunMode;

    move-result-object v1

    sget-object v2, Lcom/adview/AdViewTargeting$RunMode;->TEST:Lcom/adview/AdViewTargeting$RunMode;

    if-ne v1, v2, :cond_0

    .line 75
    const-string v1, "AdView SDK v1.7.0"

    const-string v2, "Greystripe success"

    invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 76
    :cond_0
    invoke-virtual {p1, p0}, Lcom/greystripe/android/sdk/BannerView;->removeListener(Lcom/greystripe/android/sdk/BannerListener;)V

    .line 78
    iget-object v1, p0, Lcom/adview/adapters/GreystripeAdapter;->adViewLayoutReference:Ljava/lang/ref/WeakReference;

    invoke-virtual {v1}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/adview/AdViewLayout;

    .line 79
    .local v0, adViewLayout:Lcom/adview/AdViewLayout;
    if-nez v0, :cond_1

    .line 86
    :goto_0
    return-void

    .line 82
    :cond_1
    iget-object v1, v0, Lcom/adview/AdViewLayout;->adViewManager:Lcom/adview/AdViewManager;

    invoke-virtual {v1}, Lcom/adview/AdViewManager;->resetRollover()V

    .line 83
    iget-object v1, v0, Lcom/adview/AdViewLayout;->handler:Landroid/os/Handler;

    new-instance v2, Lcom/adview/AdViewLayout$ViewAdRunnable;

    invoke-direct {v2, v0, p1}, Lcom/adview/AdViewLayout$ViewAdRunnable;-><init>(Lcom/adview/AdViewLayout;Landroid/view/ViewGroup;)V

    invoke-virtual {v1, v2}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    .line 84
    invoke-virtual {v0}, Lcom/adview/AdViewLayout;->rotateThreadedDelayed()V

    goto :goto_0
.end method
